package crm.implementor;


import crm.daoInterfaces.InquiryStateDao;
import crm.dbhandelling.Crude;
import crm.dto.InquiryState;


public class InquiryStateImp extends Crude implements InquiryStateDao
{

	private String className= new InquiryState().getClass().getName();
	@Override
	public void add(InquiryState stat) throws Exception
	{
		
		super.insert(stat);
	}

	@Override
	public void update(InquiryState stat) {
		super.update(className,"stateName", stat.getStateName(), "stateId", stat.getAutoStateId()+"");
		super.update(className,"comments", stat.getComments(), "stateId", stat.getAutoStateId()+"");
		super.update(className,"status",stat.getStatus()+"", "stateId", stat.getAutoStateId()+"");
		
	}

	@Override
	public void delete(InquiryState stat) {
		super.delete(className, "stateId", stat.getAutoStateId()+"");
		
	}

	

	@Override
	public InquiryState[] retrieveAll() throws Exception 
	{
		Object[] att=super.retreiveAll(className);
		InquiryState[] s=new InquiryState[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(InquiryState) att[i];
		return s;
		
	}

	@Override
	public InquiryState retrieve( String conditionField,
			String conditionValue) throws Exception
	{
		InquiryState s=(InquiryState) super.retreive(className, conditionField, conditionValue);
		return s;
	}

	@Override
	public InquiryState[] retrieveArray(
			String conditionField, String conditionValue) throws Exception 
	{
		Object[] att=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		InquiryState[] s=new InquiryState[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(InquiryState) att[i];
		return s;
		
	}
	public int getAutoGenratedKey()
	  {
		 int key=super.getAutoGenratedKey(className,"autostateId") ;
		 return key;
	  }
	
}
